 use [REZP8OD01]
DECLARE @startDate DATETIME, @endDate DATETIME
-- This is the date range
SET @startDate = '2010-09-21 00:00:00';
SET @endDate   = '2011-02-28 23:59:59';
 SELECT 
   bov.BookingID,bov.RecordLocator,
       convert(date,dateadd(hour,7,bov.BookingDate),103) BookingDate,
       convert(date,dateadd(hour,7,bov.ModifiedDate),103) ModifiedDate,
       bov.CreatedAgentCode,bov.CreatedOrganizationCode,
       bov.SourceAgentCode,bov.SourceOrganizationCode,
       0 AS BasisFare,
       0 AS PBXPCH,
       0 AS PSFD,
       0 AS TSF,
       0 AS VATfare,
       0 AS OtherJourneyCharge,
       0 AS CNM,
       0 AS UPG,
       0 AS RPCH,
       0 AS SAF,
       0 AS VAT,
       0 AS RFD,
       0 AS EXBG,
       0 AS INFT,
       0 AS CHG,
       0 AS RFDG,
       0 AS WTSF,
       0 AS NOR,
       0 AS NOS,
       0 AS DTF,
       0 AS OtherPaxCharge
   from [REZP8OD01].dbo.BookingVersion bov
      inner join [REZP8OD01].dbo.BookingPassengerVersion bpv
         on (bov.BookingID = bpv.BookingID)
  --    INNER JOIN REZP8OD01.dbo.PassengerJourneySegmentVersion pjsv
		--ON bpv.PassengerID = pjsv.PassengerID
	 -- inner join [REZP8OD01].dbo.PassengerJourneyChargeVersion pjcv
  --       on (pjcv.PassengerID = bpv.PassengerID AND pjcv.SegmentID=pjsv.SegmentID)
   WHERE
   NOT EXISTS
			(SELECT bpv1.PassengerID
			FROM
			    [REZP8OD01].dbo.BookingVersion bov1
                inner join [REZP8OD01].dbo.BookingPassengerVersion bpv1
                on (bov1.BookingID = bpv1.BookingID)
                INNER JOIN REZP8OD01.dbo.PassengerJourneySegmentVersion pjsv1
		        ON bpv1.PassengerID = pjsv1.PassengerID
			WHERE
				      convert(date,dateadd(hour,7,bov1.ModifiedDate),103)
					between CONVERT(date,@startDate,103) and CONVERT(date,@endDate,103)
					and bov1.Status in (2,3)
					and dateadd(hour,-7,@endDate) between bov1.VersionStartDate and bov1.VersionEndDate
					and dateadd(hour,-7,@endDate) between bpv1.VersionStartDate and bpv1.VersionEndDate
					and dateadd(hour,-7,@endDate) between pjsv1.VersionStartDate and pjsv1.VersionEndDate
					AND bov.BookingID=bov1.BookingID
				)
		AND 
      convert(date,dateadd(hour,7,bov.ModifiedDate),103)
         between CONVERT(date,@startDate,103) and CONVERT(date,@endDate,103)
      and bov.Status in (2,3)
      and dateadd(hour,-7,@endDate) between bov.VersionStartDate and bov.VersionEndDate
      and dateadd(hour,-7,@endDate) between bpv.VersionStartDate and bpv.VersionEndDate
      --and dateadd(hour,-7,@endDate) between pjsv.VersionStartDate and pjsv.VersionEndDate
      --AND DATEADD(HOUR,-7,@endDate) BETWEEN pjcv.VersionStartDate AND pjcv.VersionEndDate
      
      
group by
      bov.BookingID,bov.RecordLocator,
      convert(date,dateadd(hour,7,bov.BookingDate),103),
      convert(date,dateadd(hour,7,bov.ModifiedDate),103),
      bov.CreatedAgentCode,bov.CreatedOrganizationCode,
      bov.SourceAgentCode,bov.SourceOrganizationCode